package com.example.mall.dto;

import com.example.mall.mbg.model.Role;
import com.example.mall.mbg.model.Screen;

import java.util.List;

public class RoleDto extends Role {
    private List<Screen> screenList;
    private boolean auth1;
    private boolean auth2;
    private boolean auth3;
    private boolean auth4;
    private boolean auth5;
    private boolean auth6;

    public RoleDto(Role role) {
        setRoleid(role.getRoleid());
        setRolename(role.getRolename());
        setDescription(role.getDescription());
        setScreenids(role.getScreenids());
        setCreatetime(role.getCreatetime());
        setUpdatetime(role.getUpdatetime());
    }

    public void setScreenList(List<Screen> screenList) {
        this.screenList = screenList;
    }

    public List<Screen> getScreenList() {
        return screenList;
    }

    public String getScreenListStr() {
        String res = "";
        for (int i = 0; i < screenList.size(); i++) {
            switch (screenList.get(i).getScreenid()) {
                case 1:
                    auth1 = true;
                    break;
                case 2:
                    auth2 = true;
                    break;
                case 3:
                    auth3 = true;
                    break;
                case 4:
                    auth4 = true;
                    break;
                case 5:
                    auth5 = true;
                    break;
                case 6:
                    auth6 = true;
                    break;
            }
            res += screenList.get(i).getScreenname();
            if (i < screenList.size() - 1) {
                res += "，";
            }
        }
        return res;
    }

    public boolean getAuth1() {
        return auth1;
    }

    public boolean getAuth2() {
        return auth2;
    }

    public boolean getAuth3() {
        return auth3;
    }

    public boolean getAuth4() {
        return auth4;
    }

    public boolean getAuth5() {
        return auth5;
    }

    public boolean getAuth6() {
        return auth6;
    }
}
